home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / Python-1.4 / Lib / test / test_strop.py < prev    next >
Encoding:
Python Source  |  1998-06-24  |  481 b   |  22 lines

  1. import strop, sys
  2.  
  3. def test(name, input, output):
  4.     f = getattr(strop, name)
  5.     try:
  6.     value = f(input)
  7.     except:
  8.      value = sys.exc_type
  9.     if value != output:
  10.     print f, `input`, `output`, `value`
  11.  
  12. test('atoi', " 1 ", 1)
  13. test('atoi', " 1x", ValueError)
  14. test('atoi', " x1 ", ValueError)
  15. test('atol', "  1  ", 1L)
  16. test('atol', "  1x ", ValueError)
  17. test('atol', "  x1 ", ValueError)
  18. test('atof', "  1  ", 1.0)
  19. test('atof', "  1x ", ValueError)
  20. test('atof', "  x1 ", ValueError)
  21.  
  22.